package cn.tedu.icop.order.controller;
import cn.tedu.icop.order.pojo.param.OrderAddParam;
import cn.tedu.icop.order.service.OrderService;
import cn.tedu.icop.api.model.RestResult;
import cn.tedu.icop.api.model.RestResultUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("/order")
@Api(tags = "订单接口")
public class OrderController {
    @Autowired
    private OrderService orderService;
    /**
     * 创建订单的流程是怎样的？
     * @param orderAddParam
     * @return
     */
    @ApiOperation("创建订单")
    @PostMapping("create")
    public RestResult<String> createOrder(@RequestBody OrderAddParam orderAddParam) {
        //创建类型的接口是否返回出参,要根据业务来决定,如果后续的业务需要基于当前接口的出参(订单id)
        //做其他的操作,比如通过返回的出参(订单id),去查看订单详情,这个接口返回的订单id就是订单详情的入参
        String orderNo = orderService.createOrder(orderAddParam);
        return RestResultUtils.success(orderNo);
    }
}
